package com.feiyi.app.adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.feiyi.app.glideutils.GlideImgManager;

import java.util.List;

/**
 * 作者 : wlt
 * 创建时间:  2018-07-31
 * QQ : 1346947404
 * 邮箱:wanglt_android@163.com
 * 类说明:
 * In me the tiger sniffs the rose
 */

public class DetailPagerAdapter extends PagerAdapter {

    private List<String> mList;

    private Context mContext;

    public DetailPagerAdapter(Context mContext,List<String> mList){

        this.mContext = mContext;
        this.mList = mList;

    }


    @Override
    public int getCount() {
        return mList == null ?0:mList.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {

        ImageView imageView = new ImageView(mContext);
        GlideImgManager.loadImage(mContext,mList.get(position),imageView);
        container.addView(imageView);

        return imageView;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View)object);
    }

}
